package com.happy.controller.api;

import com.happy.service.api.ApiUserService;
import com.happy.utils.JUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by xiao on 2018/2/22.
 */

@Controller
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private ApiUserService apiUserService;

    @ResponseBody
    @RequestMapping("/getAll")
    public Object getUserAll() {

        return JUtils.RS(apiUserService.getAll());

    }

    @ResponseBody
    @RequestMapping(value = "/test")
    public String test(HttpServletRequest httpServletRequest) {

        return httpServletRequest.getServletContext().getRealPath("");

    }

    @ResponseBody
    @RequestMapping(value = "/test1")
    public Object test1() {


        return JUtils.E("失误啦");

    }

    @ResponseBody
    @RequestMapping(value = "/test2", method = RequestMethod.POST)
    public String test2(String name) {

        return "hello" + name;
    }



    @ResponseBody
    @RequestMapping(value = "/test3")
    public String test3(String text) {
        return text;

    }



}
